      logical function searcharray(length,array,value)

      integer, intent(in) :: length,value
      integer, intent(in), dimension(length) :: array
      integer :: ii


      ii=1
      do while(ii<=length)
        if(array(ii) == value) then
            searcharray = .TRUE.
            return
        end if
        ii = ii + 1
      end do

      searcharray = .FALSE.
      end
